package com.course.serviceImpl;

import java.util.Vector;

import com.course.bean.FeedbackTo;
import com.course.daoI.FeedbackDAOI;
import com.course.daoImpl.FeedbackDaoImpl;
import com.course.exception.ConnectionException;
import com.course.exception.DataNotFoundException;
import com.course.exception.LoginException;
import com.course.serviceI.FeedbackServiceI;

public class FeedbackServiceImpl implements FeedbackServiceI{
	
	
	
	FeedbackDAOI fdao=new FeedbackDaoImpl();
	
	boolean flag=false;
	Vector<FeedbackTo> vfto=null;

	public boolean cancelFeedBack(int fid) throws LoginException,
			ConnectionException {
		
		flag=fdao.cancelFeedBack(fid);
		if(flag==false)
		{
			throw new ConnectionException();
			}
       else if(fid==0) {
			throw new LoginException();
			}
		return flag;
		
		}

	public Vector<FeedbackTo> getAllFeedBack(int fid1)
			throws DataNotFoundException {
		
		vfto=fdao.getAllFeedBack(fid1);
		
		if (vfto.isEmpty()) {
			throw new DataNotFoundException();
			}
     return vfto;
		
		
		
	}

	public Vector<FeedbackTo> getFeedBack() throws DataNotFoundException {
		
		
		
		vfto=fdao.getFeedBack();
		
		if (vfto.isEmpty()) {
			throw new DataNotFoundException();
			}
     return vfto;
		
	}

	public boolean insertFeedBack(FeedbackTo fb) throws LoginException,
			ConnectionException {
		
		
		
		flag=fdao.insertFeedBack(fb);
		
		if(flag==false)
		{
			throw new ConnectionException();
			}
       else if(fb.getFeedback()==null||fb.getFeedback().equals("")) {
			throw new LoginException();
			}
		return flag;
		
		
		
	}
	
	

}
